package com.wewins.fota.bean.bo.excel.column;

import com.wewins.fota.bean.bo.excel.CellSource;
import com.wewins.fota.bean.bo.excel.Column;
import com.wewins.fota.common.constant.FotaCode;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellType;

@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class FotaLogStatusColumn implements Column {
    private Object value;

    @Builder.Default
    private CellType cellType = CellType.STRING;

    @Override
    public void fillCell(CellSource source) {
        Cell cell = source.getCell();
        if (value instanceof FotaCode) {
            cell.setCellValue(((FotaCode) value).getMessage());
        } else if (value instanceof Integer) {
            cell.setCellValue(FotaCode.getInstance((Integer) value).getMessage());
        } else {
            cell.setCellValue(FotaCode.NONE.getMessage());
        }
    }
}
